#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // 创建菜单栏
    QMenuBar* menubar = new QMenuBar();
    this->setMenuWidget(menubar);

    // 创建菜单
    // 在文本后面加上&符号，表示快捷键
    QMenu* menu1 = new QMenu("文件(&F)");
    QMenu* menu2 = new QMenu("编辑(&E)");
    menubar->addMenu(menu1);
    menubar->addMenu(menu2);

    // 创建子菜单
    QMenu* chile_menu1 = new QMenu("子菜单1(&T)");
    menu1->addMenu(chile_menu1);

    // 给菜单添加菜单项
    QAction* action1 = new QAction("新建(&U)");
    QAction* action5 = new QAction("菜单项2(&K)");
    QAction* action_chile = new QAction("子菜单项1(&L)");
    menu1->addAction(action1);
    menu2->addAction(action5);
    chile_menu1->addAction(action_chile);
}

MainWindow::~MainWindow()
{
    delete ui;
}

